package org.springside.examples.miniweb.service.cm;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import org.springside.examples.miniweb.entity.cm.Company;
import org.springside.examples.miniweb.dao.cm.CompanyDao;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

@Service
@Transactional
public class CompanyManager {
	@Autowired
	private CompanyDao companyDao;

	// Company Manager //
	@Transactional(readOnly = true)
	public Company getCompany(Long id) {
		return companyDao.get(id);
	}

	@Transactional(readOnly = true)
	public List<Company> getAllCompany() {
		return companyDao.getAll();
	}

	@Transactional(readOnly = true)
	public Page<Company> searchCompany(final Page<Company> page, final List<PropertyFilter> filters) {
		return companyDao.findPage(page, filters);
	}

	public void saveCompany(Company company) {
		companyDao.save(company);
	}

	public void deleteCompany(Long id) {
		companyDao.delete(id);
	}
}
